package BTTL06;

public class Phanso implements PhanSoItf {
	private int tu;
	private int mau;
	
	Phanso(){
		tu = 0;
		mau = 1;
	}
	
	Phanso(int a, int b){
		tu = a;
		mau = b;
	}
	
	Phanso(Phanso ps){
		tu = ps.tu;
		mau = ps.mau;
	}
	
	@Override
	public int gettu() {
		return this.tu;
	}
	@Override
	public int getmau() {
		return this.mau;
	}
	@Override
	public Phanso rutgon() {
		int uc = UCLN();
		this.tu = this.tu/uc;
		this.mau = this.mau/uc;
		return this;
	}
	
	public int UCLN (){
		int a = this.tu; 
		int b = this.mau;
		while (a != b) {
			if(a>b){
				a -= b;
			}
			if (a<b){
				b -=a;
			}
			
		}
		return a;
	}

	@Override
	public void settu(int a) {
		this.tu = a;
	}

	@Override
	public void setmau(int a) {
		this.mau = a;
	}
	
	public void xuat()
	{
		System.out.println(tu + "/" + mau);
	}

}
